package com.joysuch.wwyt.api.mh.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import com.joysuch.wwyt.dataperm.enums.DataPermissionFilterType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_mh_platform_point")
@SQLDelete(sql = "update wwyt_mh_platform_point set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_mh_platform_point set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class MhPlatformPoint implements Serializable {
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @ApiModelProperty("主键id")
    private Long id;

    @ApiModelProperty("监测点id")
    @DataPermissionField(type = DataPermissionFilterType.JOIN_TABLE,
            sqlColumn = "point_id", joinInfo = {"wwyt_mh_monitoring_point", "id",
            "responsible_dept" })
    private Long pointId;

    @ApiModelProperty("平台id")
    private Long platformId;

    @ApiModelProperty("监测点编码")
    private String pointCode;

    @ApiModelProperty("监测点名称")
    private String pointName;

    @ApiModelProperty("监测点类型id")
    private Long pointTypeId;

    @ApiModelProperty("对接平台编号/名称")
    private String codeOrName;

    @ApiModelProperty("校正系数")
    private Double correctionFactor;

    @ApiModelProperty("接入开关:0关,1开")
    private Integer switchState;

    //通用字段
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    private Long createBy;

    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    private java.time.LocalDateTime createTime;

    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    private Long updateBy;

    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    private java.time.LocalDateTime updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    private String deleteFlag;
}
